package com.jinzecloud.reportapproval.controller;

import com.jinzecloud.reportapproval.vo.AdminVo;
import com.jinzecloud.reportapproval.service.AdminService;
import com.jinzecloud.reportapproval.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@RestController
@RequestMapping("/admin")
@Api(tags = "登录接口", description = "登录接口", value = "登录接口")
public class LoginController {

    @Autowired
    private AdminService tbAdminService;

    @ApiOperation(value = "验证码",notes = "验证码")
    @GetMapping("/captchaJpg")
    public void captcha(HttpServletRequest request, HttpServletResponse response, String uuid) throws Exception {
        tbAdminService.getCode(request,response,uuid);
    }

    @PostMapping("/login")
    public R login(@RequestBody AdminVo adminVo) throws Exception{
        R r = tbAdminService.login(adminVo);
        return r;
    }

    @GetMapping("/Logout")
    public R Logout(String token) {
        Map<String, Object> map = tbAdminService.Logout(token);
        return R.ok().put("data",map);
    }

}
